import smtplib

from flask_mail import Message
from app import mail
from app.config import Config, DevelopmentConfig


def send_verification_email(email, code):
    msg = Message(
        subject="验证码",
        sender="ljz2020comeon@163.com",
        recipients=[email],
        body=f"您的验证码是：{code}，有效期5分钟，请勿泄露给他人。"
    )

    try:
        mail.send(msg)

        return True
    except Exception as e:
        print(f"邮件发送失败: {e}")
        return False
